Android Architecture blueprints TodoApp
ファイルの構造から把握したい。
fragment別にpackageしてViewModelをそこに置く。(Activityは1つ)
viewModelFactoryを作っておいて、各々のfragmentのviewModelは by でプロパティ設定できるようにしておく
data packageにsource, data型(task, result)
sourceには、default repositoryを置いて、local, remoteは別途repository を置く
Daoを定義して、その後にdatabase接続に関する具体的な処理を書く。
https://gyazo.com/af07fb12d32ae6b1e804c003c918911f
あとは、
if (BuildConfig.DEBUG) Timber.plant(DebugTree())
拡張関数は?
View.setupSnackBar(lifecycleOnwer, LiveData<Event<Int>>, Int)
View.showSnackBar(String, Int)
fun Fragment.setupRefreshLayout(ScrollChildSwipeRefreshLayout,View?)
fun Fragment.getViewModelFactory(): ViewModelFactory {.... return ViewModelFactory(repo)}
まだ馴染みがない
Event.ktの部分 Eventの状態を通知できるようにしたい? liveDataを使うため
espressoの部分 test用?
activityは、UIの骨格の設定のみ(navigation含む)
setContent, setNavigationDrawer, setSupportActionBar
fragmentがUI
viewModelScopeの導入
repository以下は、 suspend関数